<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //async和await的注意点
        //1.await会等待resolve或者reject之后执行下面的代码
        function fn1(){
            return new Promise(resolve=>{
                setTimeout(() => {
                    // resolve(111);
                    //如果不执行resolve或者reject await会一直等待，await下面的代码也不会执行
                }, 2000);
            })
        }
        (async function(){
            let res = await fn1();
            console.log(res);
            console.log(222);

        })();


        //2. await之后是异步代码，之前是同步代码，
        // await模拟then的执行，await之后是微任务
        async function fn(){
            
        }
    </script>
</body>
</html>